<?php

class Application_Model_DbTable_Product extends Zend_Db_Table_Abstract
{

    protected $_name = 'txy_product';

	public function addNewProduct($productdata){
	$key_words=$productdata['product_key_words'];
    	$key_words_array=explode(',', $key_words);
    	$keyWordsModel=new Application_Model_DbTable_Keywords();
    	$this->_db->beginTransaction();
    	try{
	    	$this->insert($productdata);
	    	$article_id=$this->_db->lastInsertId();
	    	foreach ($key_words_array as $key_word){
	    		$keyWordsModel->addKeyWords(array('article_id'=>$article_id,'key_words'=>$key_word,'item_type'=>'1'));
	    	}
	    	$this->_db->commit();
    	} catch (Exception $e){
    		$this->_db->rollBack();
    		$e->getMessage();
    	}
	}
}

